home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / nwlib15.zip / DEMO.ZIP / NDS.PAS < prev    next >
Pascal/Delphi Source File  |  1996-03-03  |  4KB  |  143 lines

  1. unit Nds;
  2.  
  3. interface
  4.  
  5. uses 
  6.      SysUtils,
  7.      WinTypes, 
  8.      WinProcs, 
  9.      Classes, 
  10.      Graphics, 
  11.      Forms, 
  12.      dialogs,
  13.      Controls, 
  14.      Buttons,
  15.      StdCtrls, 
  16.      ExtCtrls, 
  17.      Nwtools, 
  18.      Nwnds, 
  19.      Nwlib;
  20.  
  21. type
  22.   TwinNDS = class(TForm)
  23.     OKBtn: TBitBtn;
  24.     Bevel1: TBevel;
  25.     Label1: TLabel;
  26.     NDScontext: TEdit;
  27.     NWNDS1: TNWNDS;
  28.     NWTools1: TNWTools;
  29.     binderyContext: TEdit;
  30.     Label2: TLabel;
  31.     NWLib1: TNWLib;
  32.     serverDN: TEdit;
  33.     Label3: TLabel;
  34.     whoAmI: TEdit;
  35.     Label4: TLabel;
  36.     bLogin: TButton;
  37.     bLogout: TButton;
  38.     root: TEdit;
  39.     Label5: TLabel;
  40.     procedure FormShow(Sender: TObject);
  41.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  42.     procedure bLoginClick(Sender: TObject);
  43.     procedure bLogoutClick(Sender: TObject);
  44.   private
  45.     { Private declarations }
  46.   public
  47.     { Public declarations }
  48.   end;
  49.  
  50. var
  51.   winNDS: TwinNDS;
  52.  
  53. implementation
  54.  
  55. {$R *.DFM}
  56.  
  57. procedure TwinNDS.FormShow(Sender: TObject);
  58.   var
  59.     nserver     : TNWConnHandle    ;
  60.     attrRights  : TNWDSAttrRights  ;
  61.     entryRights : TNWDSEntryRights ;
  62.     smsRights   : TNWDSSMSRights   ;
  63.   begin
  64.     if ndsInit then
  65.       begin
  66.         binderyContext.text := ndsGetBinderyContextName(getPrimaryServerID) ;
  67.         serverDN.text       := ndsGetServerDN(getPrimaryServerID) ;
  68.         whoAmI.text         := ndsWhoAmI ;
  69.         root.text           := ndsGetRootName(whoami.text) ;
  70.         ndscontext.text     := ndsGetContextName ;
  71.         { Show Some Rights }
  72.         if ndsGetattrRights(ndsWhoAmI,
  73.                    '_some_attribute_List_',attrRights) then
  74.           okbox('Attribute Rights:;;' +
  75.                 iif(attrRights.compare    ,'Compare;','') +
  76.                 iif(attrRights.read       ,'Read;','') +
  77.                 iif(attrRights.write      ,'Write;','') +
  78.                 iif(attrRights.self       ,'Self;','') +
  79.                 iif(attrRights.supervisor,'Supervisor;','')) ;
  80.         if ndsGetEntryRights(ndsWhoAmI,
  81.                    'printServer.marketing',entryRights) then
  82.           okbox('Entry Rights:;;' +
  83.                 iif(entryRights.browse    ,'Browse;','') +
  84.                 iif(entryRights.add       ,'Add;','') +
  85.                 iif(entryRights.delete    ,'Delete;','') +
  86.                 iif(entryRights.rename    ,'Rename;','') +
  87.                 iif(entryRights.supervisor,'Supervisor;','')) ;
  88.         if ndsGetSMSRights(ndsWhoAmI,
  89.                  '_put_sms_data_here_',smsRights) then
  90.           okbox('SMS Rights:;;' +
  91.                 iif(smsRights.scan   ,'Scan;','') +
  92.                 iif(smsRights.backup ,'Backup;','') +
  93.                 iif(smsRights.restore,'Restore;','') +
  94.                 iif(smsRights.rename ,'Rename;','') +
  95.                 iif(smsRights.delete ,'Delete;','') +
  96.                 iif(smsRights.admin  ,'Admin;','')) ;
  97.       end
  98.     else
  99.       AlertBox('Novell Directory Services Not Installed') ;
  100.   end;
  101.  
  102. procedure TwinNDS.FormClose(Sender: TObject; var Action: TCloseAction);
  103.   begin
  104.     { must shut down nds communications! }
  105.     ndsClose;
  106.  
  107.   end;
  108.  
  109. procedure TwinNDS.bLoginClick(Sender: TObject);
  110.   var
  111.     ctext : string ;
  112.     cUserID : string ;
  113.   begin
  114.     ctext   := space(20) ;
  115.     cUserID := space(20) ;
  116.     if inputQuery('NDS Login','Type Your Login ID:',cUserID) and
  117.        inputQuery('NDS Login','Type Your Password:',ctext) then
  118.       begin
  119.          if ndsPassCheck(cUserID,ctext) and  { in case already logged in, } 
  120.             ndsLogin(cUserID,ctext) then     { don't kill login on bad attempt}
  121.            begin
  122.              bLogout.enabled := True ;
  123.              okBox('Login OK!') ;
  124.            end
  125.          else
  126.            alertBox('Incorrect UserID/Password;;Try Again') ;
  127.       end;
  128.   end;
  129.  
  130. procedure TwinNDS.bLogoutClick(Sender: TObject);
  131.   begin
  132.     if YesNoBox('Logging Out;;Are You Sure?') and
  133.        ndsLogout then
  134.       begin
  135.         bLogout.enabled := False ;
  136.         okBox('logged out!') ;
  137.       end
  138.     else
  139.       alertBox('You Are Still Logged In') ;
  140.   end;
  141.  
  142. end.
  143.